package com.ruoyi.InboundManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.InboundManagement.domain.OtherInbound;
import com.ruoyi.InboundManagement.service.IOtherInboundService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 其他入库管理Controller
 * 
 * @author admin
 * @date 2024-07-03
 */
@RestController
@RequestMapping("/InboundManagement/otherInbound")
public class OtherInboundController extends BaseController
{
    @Autowired
    private IOtherInboundService otherInboundService;

    /**
     * 查询其他入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:otherInbound:list')")
    @GetMapping("/list")
    public TableDataInfo list(OtherInbound otherInbound)
    {
        startPage();
        List<OtherInbound> list = otherInboundService.selectOtherInboundList(otherInbound);
        return getDataTable(list);
    }

    /**
     * 导出其他入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:otherInbound:export')")
    @Log(title = "其他入库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OtherInbound otherInbound)
    {
        List<OtherInbound> list = otherInboundService.selectOtherInboundList(otherInbound);
        ExcelUtil<OtherInbound> util = new ExcelUtil<OtherInbound>(OtherInbound.class);
        util.exportExcel(response, list, "其他入库管理数据");
    }

    /**
     * 获取其他入库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:otherInbound:query')")
    @GetMapping(value = "/{otherId}")
    public AjaxResult getInfo(@PathVariable("otherId") Long otherId)
    {
        return success(otherInboundService.selectOtherInboundByOtherId(otherId));
    }

    /**
     * 新增其他入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:otherInbound:add')")
    @Log(title = "其他入库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OtherInbound otherInbound)
    {
        return toAjax(otherInboundService.insertOtherInbound(otherInbound));
    }

    /**
     * 修改其他入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:otherInbound:edit')")
    @Log(title = "其他入库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OtherInbound otherInbound)
    {
        return toAjax(otherInboundService.updateOtherInbound(otherInbound));
    }

    /**
     * 删除其他入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:otherInbound:remove')")
    @Log(title = "其他入库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{otherIds}")
    public AjaxResult remove(@PathVariable Long[] otherIds)
    {
        return toAjax(otherInboundService.deleteOtherInboundByOtherIds(otherIds));
    }
}
